<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :span="24">
            <a-breadcrumb>
              <a-breadcrumb-item href="">
                <a-icon type="home" />
                <span>首页</span>
              </a-breadcrumb-item>
              <a-breadcrumb-item href="">
                <a-icon type="user" />
                <span>招标管理</span>
              </a-breadcrumb-item>
              <a-breadcrumb-item href="">
                <span>
                <template v-if="this.id !== ''"> <a-icon type="edit" />招标详情</template>
                  <template v-else> <a-icon type="folder-add" />招标添加</template>
                </span>
              </a-breadcrumb-item>
            </a-breadcrumb>
          </a-col>
          <a-col :span="24">&nbsp;</a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    <div class="table-page-search-wrapper">
      <a-form :form="form">
        <a-row :gutter="24">
          <a-col :span="18">
            <a-form-item label="" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-button-group>
                <a-button type="primary" @click="goBack"> <a-icon type="left" />返回 </a-button>
              </a-button-group>
            </a-form-item>
          </a-col>
          <a-col :span="6" :style="{ textAlign: 'right' }">
              <!--明细导入导出-->
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-item label="id" hidden="true">
              <a-input v-decorator="['id']" />
            </a-form-item>
            <a-form-item label="招标编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['tenderCode']" :disabled="disabledOne" placeholder="请输入招标编码"></a-input>
            </a-form-item>
            <a-form-item label="主责部室编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['mainDepartId']" :disabled="disabledOne" placeholder="请输入主责部室编码"></a-input>
            </a-form-item>
            <a-form-item label="经办人编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['agentId']" :disabled="disabledOne" placeholder="请输入经办人编码"></a-input>
            </a-form-item>
            <a-form-item label="合同编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['contractId']" :disabled="disabledOne" placeholder="请输入合同编码"></a-input>
            </a-form-item>
            <a-form-item label="律师审核" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-checkbox v-decorator="['lawyerApproved']"   :disabled="disabledOne" :checked="lawyerApproved">
                是
              </a-checkbox>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="项目名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['projectName']" :disabled="disabledOne" placeholder="请输入项目名称"></a-input>
            </a-form-item>
            <a-form-item label="主责部室名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['mainDepartName']" :disabled="disabledOne" placeholder="请输入主责部室名称"></a-input>
            </a-form-item>
            <a-form-item label="经办人名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['agentName']" :disabled="disabledOne" placeholder="请输入经办人名称"></a-input>
            </a-form-item>
            <a-form-item label="合同名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['contractName']" :disabled="disabledOne" placeholder="请输入合同名称"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['status']" :disabled="disabledOne" placeholder="请输入状态"></a-input>
            </a-form-item>
            <a-form-item label="招标清单类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag :value="'请选择'"  :triggerChange="true" dictCode="tenderType" :disabled="disabledOne"
                                 v-decorator="['tenderType',{ rules: [{ required:true, message: '必填项' }] }]" placeholder="请输入招标清单类型"/>
            </a-form-item>
            <a-form-item label="招标方式" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag :value="'请选择'"  :triggerChange="true" dictCode="tenderWay" :disabled="disabledOne"
                                 v-decorator="['tenderWay',{ rules: [{ required:true, message: '必填项' }] }]" placeholder="请输入招标方式"/>
            </a-form-item>
            <a-form-item label="控制价" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input-number v-decorator="['controlPrice']" :disabled="disabledOne"  placeholder="请输入控制价" style="width: 100%"/>
            </a-form-item>
            <a-form-item label="" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-button type="primary" @click="" > 附件上传 </a-button>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        class="j-table-force-nowrap">
      </a-table>
    </div>

    <mms-tender-details-modal ref="modalForm" @ok="modalFormOk"></mms-tender-details-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@lone/lone-vue/src/utils/mixin.js'
  import { JeecgListMixin } from '@lone/lone-vue/src/mixins/JeecgListMixin'
  import MmsTenderDetailsModal from './modules/MmsTenderDetailsModal'
  import JDate from '@lone/lone-vue/src/components/jeecg/JDate'
  import { postAction, putAction, downFile, deleteAction, getAction } from '@lone/lone-vue/src/api/manage'
  import Vue from 'vue'
  export default {
    name: 'MmsTenderDetailsList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      JDate,
      MmsTenderDetailsModal
    },
    props:{
      //判断是编辑还是新增
      status:{
        type:String,
        required:false
      },
      //判断是编辑Id
      id:{
        type:String,
        required:false
      }


    },
    watch:{
      status: {
        handler(newVal, oldVal) {
          this.loadFormData()
        },
        immediate: true
      }
    },
    data () {
      return {
        description: 'mms_tender_details管理页面',
        // 表头PKL,
        top: 10,
        dateFormat: 'YYYY-MM-DD HH:mm:ss',
        // 表头
        editingKey: '',
        dataSource: [],
        lawyerApproved: false,
        form: this.$form.createForm(this),
        statusMethod: 'ADD',/*???*/
        tenderType:'',
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 8 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'物资编码',
            align:"center",
            dataIndex: 'materialCode'
          },
          {
            title:'物资名称',
            align:"center",
            dataIndex: 'materialName'
          },
          {
            title:'规格型号',
            align:"center",
            dataIndex: 'specs'
          },
          {
            title:'投标单价',
            align:"center",
            dataIndex: 'tenderUnitPrice'
          },
          {
            title:'控制单价',
            align:"center",
            dataIndex: 'controlUnitPrice'
          },
          {
            title:'数量',
            align:"center",
            dataIndex: 'applyNum'
          },
          {
            title:'总金额',
            align:"center",
            dataIndex: 'totalPrice'
          },
          {
            title:'计量单位',
            align:"center",
            dataIndex: 'unit'
          },
          {
            title:'品牌编码',
            align:"center",
            dataIndex: 'brandId'
          },
          {
            title:'品牌名称',
            align:"center",
            dataIndex: 'brandName'
          },
          {
            title:'使用寿命',
            align:"center",
            dataIndex: 'employAge'
          },
          {
            title:'质保期限',
            align:"center",
            dataIndex: 'guaranteePeriod',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'技术参数',
            align:"center",
            dataIndex: 'techPar'
          },
          {
            title:'备注',
            align:"center",
            dataIndex: 'remarks'
          }
        ],
        url: {
          exportXlsUrl: "/ht/mmsTenderDetails/exportXls",
          importExcelUrl: "ht/mmsTenderDetails/importExcel",

        },
        dictOptions:{},
      }
    },
    created() {
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      handleChange(e) {
        this.lawyerApproved = e.target.checked;
        this.$nextTick(() => {
          this.form.validateFields(['lawyerApproved'], { force: true });
        });
      },
      loadFormData() {
        let that = this;
        if(this.id !== ''){
          let paramsObject = {id: this.id};
          getAction('/ht/mmsTender/queryDetailsById', paramsObject).then((res) => {
            if (res.success) {
              let result = res.result;
              Vue.prototype.$copyProperties(that.form, result,{status: '新建', compileTime: Vue.prototype.$formatDate()}, that.dataSource);
            }
          });
        }
        that.disabledOne = true;
      },
      goBack(){
        this.$emit('prevStep')
      },
      initDictConfig(){
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>